import React, { memo,Component } from 'react'
import { Image,Avatar,Button,Input,Select, message  } from 'antd';
import './index.css'
import { StudentInfo } from '../../utils/model';
import {baseUrl} from '../../assets/baseUrl'
// import {getUserInfo,getSchoollist,getClasslist,setMyBasicInfo} from '@/api/user'
const BaseUrl = baseUrl()
const { Option } = Select;

class Permission extends Component{
    static contextType = StudentInfo
    constructor(props) {
        super(props);
        this.state = {
            level: null,
            schoolLevel:null
        }
    }
    componentDidMount(){
        this.setState({
            level: this.context?.studentInfo?.level,
            schoolLevel: this.context?.studentInfo?.schoollevel
        })
    }

    schoolPermission=()=>{
        let {schoolLevel} = this.state
        // debugger
        if(schoolLevel?.split(',').includes('999')) {
            this.props.history.push('/home/setting/permission/schoolPermission');
        }
        else {
            message.error('您的账号暂无校园圈权限指派权限哦~')
        }
    }

    classPermission=()=>{
        let {level} = this.state
        if(level<10) {
            message.error('您的账号暂无班级圈权限指派权限哦~')
        }
        else {
            this.props.history.push('/home/setting/permission/classPermission');
        }
    }
    render(){
        const {} = this.state
        
        return (
            <div className="setting-opration permission">
                <div className="permission-class inner">
                    <div className="title">班级权限</div>
                    <div className="chahua"></div>
                    <div className="text">包括班级圈各功能使用的身份及权限指派</div>
                    <div className="button" onClick={this.classPermission.bind(this)}>立即指派</div>
                </div>
                <div className="permission-school inner">
                    <div className="title">校园权限</div>
                    <div className="chahua"></div>
                    <div className="text">包括校园圈各模块信息及用户管理权限指派</div>
                    <div className="button" onClick={this.schoolPermission.bind(this)}>立即指派</div>
                </div>
            </div>
        )
    }
}
export default memo(Permission)